
#include "latest_news.h"

LatestNews::LatestNews(QWidget *parent) :
        QWidget(parent)
{
    ui.setupUi(this);
    ui.label_date->setAttribute(Qt::WA_TranslucentBackground);
    ui.frame_back->setAutoFillBackground(true);//设置窗体自动填充背景
}

LatestNews::~LatestNews()
{

}

void LatestNews::setPic(const QImage &image)
{
    QPalette palette;
    QPixmap pixmap;
    pixmap.convertFromImage(image);
    palette.setBrush(QPalette::Background,QBrush(pixmap));
    ui.frame_back->setPalette(palette);
}
void LatestNews::setPic(const QString &imagePath)
{
    QPalette palette = ui.frame_back->palette();
    palette.setBrush(QPalette::Background,QPixmap(imagePath).scaled(ui.frame_back->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
    ui.frame_back->setPalette(palette);
}

void LatestNews::setDate(const QString &date)
{
    ui.label_date->setText(date);
}

void LatestNews::setMask(const QString &str)
{
    ui.label_mask->setText(str);
}



